home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60src.lha / Vim / vim60 / src / testdir / test3.in < prev    next >
Encoding:
Text File  |  2001-09-09  |  8.9 KB  |  904 lines

  1. /* vim: set cin ts=4 sw=4 : */
  2.  
  3. Test for 'cindent'
  4.  
  5. STARTTEST
  6. :so small.vim
  7. :set nocompatible viminfo+=nviminfo
  8. :edit                " read modeline
  9. /start of AUTO
  10. =/end of AUTO
  11. ENDTEST
  12.  
  13. /* start of AUTO matically checked */
  14. {
  15.     if (test)
  16.         cmd1;
  17.     cmd2;
  18. }
  19.  
  20. {
  21.     if (test)
  22.         cmd1;
  23.     else
  24.         cmd2;
  25. }
  26.  
  27. {
  28.     if (test)
  29.     {
  30.         cmd1;
  31.         cmd2;
  32.     }
  33. }
  34.  
  35. {
  36.     if (test)
  37.     {
  38.         cmd1;
  39.         else
  40.     }
  41. }
  42.  
  43. {
  44.     while (this)
  45.         if (test)
  46.             cmd1;
  47.     cmd2;
  48. }
  49.  
  50. {
  51.     while (this)
  52.         if (test)
  53.             cmd1;
  54.         else
  55.             cmd2;
  56. }
  57.  
  58. {
  59.     if (test)
  60.     {
  61.         cmd;
  62.     }
  63.  
  64.     if (test)
  65.         cmd;
  66. }
  67.  
  68. {
  69.     if (test) {
  70.         cmd;
  71.     }
  72.  
  73.     if (test) cmd;
  74. }
  75.  
  76. {
  77.     cmd1;
  78.     for (blah)
  79.         while (this)
  80.             if (test)
  81.                 cmd2;
  82.     cmd3;
  83. }
  84.  
  85. {
  86.     cmd1;
  87.     for (blah)
  88.         while (this)
  89.             if (test)
  90.                 cmd2;
  91.     cmd3;
  92.  
  93.     if (test)
  94.     {
  95.         cmd1;
  96.         cmd2;
  97.         cmd3;
  98.     }
  99. }
  100.  
  101.  
  102. /* Test for 'cindent' do/while mixed with if/else: */
  103.  
  104. {
  105.     do
  106.         if (asdf)
  107.             asdfasd;
  108.     while (cond);
  109.  
  110.     do
  111.         if (asdf)
  112.             while (asdf)
  113.                 asdf;
  114.     while (asdf);
  115. }
  116.  
  117. /* Test for 'cindent' with two ) on a continuation line */
  118. {
  119.     if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d
  120.             aal;sdkjf  ( ;asldfkja;sldfk
  121.                     al;sdjfka ;slkdf ) sa;ldkjfsa dlk;)
  122.         line up here;
  123. }
  124.  
  125.  
  126. /* C++ tests: */
  127.  
  128. // foo()        these three lines should remain in column 0
  129. // {
  130. // }
  131.  
  132. /* Test for continuation and unterminated lines: */
  133. {
  134.     i = 99 + 14325 +
  135.         21345 +
  136.         21345 +
  137.         21345 + ( 21345 +
  138.                 21345) +
  139.         2345 +
  140.         1234;
  141.     c = 1;
  142. }
  143.  
  144. /*
  145.    testje for indent with empty line
  146.  
  147.    here */
  148.  
  149. {
  150.     if (testing &&
  151.             not a joke ||
  152.             line up here)
  153.         hay;
  154.     if (testing &&
  155.             (not a joke || testing
  156.             )line up here)
  157.         hay;
  158.     if (testing &&
  159.             (not a joke || testing
  160.              line up here))
  161.         hay;
  162. }
  163.  
  164.  
  165. {
  166.     switch (c)
  167.     {
  168.         case xx:
  169.             do
  170.                 if (asdf)
  171.                     do
  172.                         asdfasdf;
  173.                     while (asdf);
  174.                 else
  175.                     asdfasdf;
  176.             while (cond);
  177.         case yy:
  178.         case xx:
  179.         case zz:
  180.             testing;
  181.     }
  182. }
  183.  
  184. {
  185.     if (cond) {
  186.         foo;
  187.     }
  188.     else
  189.     {
  190.         bar;
  191.     }
  192. }
  193.  
  194. {
  195.     if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf
  196.             alsdkfj (asldk;fj
  197.                     awith cino=(0 ;lf this one goes to below the paren with ==
  198.                             ;laksjfd ;lsakdjf ;alskdf asd)
  199.                     asdfasdf;)))
  200.         asdfasdf;
  201. }
  202.  
  203.     int
  204. func(a, b)
  205.     int a;
  206.     int c;
  207. {
  208.     if (c1 && (c2 ||
  209.             c3))
  210.         foo;
  211.     if (c1 &&
  212.             (c2 || c3)
  213.        )
  214. }
  215.  
  216. {
  217.     while (asd)
  218.     {
  219.         if (asdf)
  220.             if (test)
  221.                 if (that)
  222.                 {
  223.                     if (asdf)
  224.                         do
  225.                             cdasd;
  226.                         while (as
  227.                                 df);
  228.                 }
  229.                 else
  230.                     if (asdf)
  231.                         asdf;
  232.                     else
  233.                         asdf;
  234.         asdf;
  235.     }
  236. }
  237.  
  238. {
  239.     s = "/*"; b = ';'
  240.         s = "/*"; b = ';';
  241.     a = b;
  242. }
  243.  
  244. {
  245.     switch (a)
  246.     {
  247.         case a:
  248.             switch (t)
  249.             {
  250.                 case 1:
  251.                     cmd;
  252.                     break;
  253.                 case 2:
  254.                     cmd;
  255.                     break;
  256.             }
  257.             cmd;
  258.             break;
  259.         case b:
  260.             {
  261.                 int i;
  262.                 cmd;
  263.             }
  264.             break;
  265.         case c: {
  266.                     int i;
  267.                     cmd;
  268.                 }
  269.         case d: if (cond &&
  270.                         test) {        /* this line doesn't work right */
  271.                     int i;
  272.                     cmd;
  273.                 }
  274.                 break;
  275.     }
  276. }
  277.  
  278. {
  279.     if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) &&
  280.             (bp_to->b_p_initialized ||
  281.              (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
  282.         return;
  283. label :
  284.     asdf = asdf ?
  285.         asdf : asdf;
  286.     asdf = asdf ?
  287.         asdf: asdf;
  288. }
  289.  
  290. /* Special Comments    : This function has the added complexity (compared  */
  291. /*                    : to addtolist) of having to check for a detail     */
  292. /*                    : texture and add that to the list first.             */
  293.  
  294. char *(array[100]) = {
  295.     "testje",
  296.     "foo",
  297.     "bar",
  298. }
  299.  
  300. {
  301.     struct Type
  302.     {
  303.         int i;
  304.         char *str;
  305.     } var[] =
  306.     {
  307.         0, "zero",
  308.         1, "one",
  309.         2, "two",
  310.         3, "three"
  311.     };
  312.  
  313.     float matrix[3][3] =
  314.     {
  315.         {
  316.             0,
  317.             1,
  318.             2
  319.         },
  320.         {
  321.             3,
  322.             4,
  323.             5
  324.         },
  325.         {
  326.             6,
  327.             7,
  328.             8
  329.         }
  330.     };
  331. }
  332.  
  333. {
  334.     /* blah ( blah */
  335.     /* where does this go? */
  336.  
  337.     /* blah ( blah */
  338.     cmd;
  339.  
  340.     func(arg1,
  341.             /* comment */
  342.             arg2);
  343.     a;
  344.     {
  345.         b;
  346.         {
  347.             c; /* Hey, NOW it indents?! */
  348.         }
  349.     }
  350.  
  351.     {
  352.         func(arg1,
  353.                 arg2,
  354.                 arg3);
  355.         /* Hey, what am I doing here?  Is this coz of the ","? */
  356.     }
  357. }
  358.  
  359. main ()
  360. {
  361.     if (cond)
  362.     {
  363.         a = b;
  364.     }
  365.     if (cond) {
  366.         a = c;
  367.     }
  368.     if (cond)
  369.         a = d;
  370.     return;
  371. }
  372.  
  373. {
  374.     case 2: if (asdf &&
  375.                     asdfasdf)
  376.                 aasdf;
  377.             a = 9;
  378.     case 3: if (asdf)
  379.                 aasdf;
  380.             a = 9;
  381.     case 4:    x = 1;
  382.                y = 2;
  383.  
  384. label:    if (asdf)
  385.             here;
  386.  
  387. label:  if (asdf &&
  388.                 asdfasdf)
  389.         {
  390.         }
  391.  
  392. label:  if (asdf &&
  393.                 asdfasdf) {
  394.             there;
  395.         }
  396.  
  397. label:  if (asdf &&
  398.                 asdfasdf)
  399.             there;
  400. }
  401.  
  402. {
  403.     /*
  404.        hello with ":set comments= cino=c5"
  405.      */
  406.  
  407.     /*
  408.        hello with ":set comments= cino="
  409.      */
  410. }
  411.  
  412.  
  413. {
  414.     if (a < b) {
  415.         a = a + 1;
  416.     } else
  417.         a = a + 2;
  418.  
  419.     if (a)
  420.         do {
  421.             testing;
  422.         } while (asdfasdf);
  423.     a = b + 1;
  424.     asdfasdf
  425. }
  426.  
  427. class bob
  428. {
  429.     int foo() {return 1;}
  430.         int bar;
  431. }
  432.  
  433. main()
  434. {
  435. while(1)
  436. if (foo)
  437. {
  438. bar;
  439. }
  440. else {
  441. asdf;
  442. }
  443. misplacedline;
  444. }
  445.  
  446. {
  447.     if (clipboard.state == SELECT_DONE
  448.     && ((row == clipboard.start.lnum
  449.     && col >= clipboard.start.col)
  450.     || row > clipboard.start.lnum))
  451. }
  452.  
  453. {
  454. if (1) {i += 4;}
  455. where_am_i;
  456. return 0;
  457. }
  458.  
  459. {
  460. {
  461. } // sdf(asdf
  462. if (asdf)
  463. asd;
  464. }
  465.  
  466. {
  467. label1:
  468. label2:
  469. }
  470.  
  471. {
  472. int fooRet = foo(pBar1, false /*fKB*/,
  473.     true /*fPTB*/, 3 /*nT*/, false /*fDF*/);
  474. f() {
  475. for ( i = 0;
  476.     i < m;
  477.     /* c */ i++ ) {
  478. a = b;
  479. }
  480. }
  481. }
  482.  
  483. {
  484.     f1(/*comment*/);
  485.     f2();
  486. }
  487.  
  488. {
  489. do {
  490. if (foo) {
  491. } else
  492. ;
  493. } while (foo);
  494. foo();    // was wrong
  495. }
  496.  
  497. int x;        // no extra indent because of the ;
  498. void func()
  499. {
  500. }
  501.  
  502. char *tab[] = {"aaa",
  503.     "};", /* }; */ NULL}
  504.     int indented;
  505. {}
  506.  
  507. char *tab[] = {"aaa",
  508.     "xx", /* xx */};    /* asdf */
  509. int not_indented;
  510.  
  511. {
  512.     do {
  513.         switch (bla)
  514.         {
  515.             case 1: if (foo)
  516.                         bar;
  517.         }
  518.     } while (boo);
  519.                     wrong;
  520. }
  521.  
  522. int    foo,
  523.     bar;
  524. int foo;
  525.  
  526. char * xx = "asdf\
  527.     foo\
  528.     bor";
  529. int x;
  530.  
  531. /* end of AUTO */
  532.  
  533. STARTTEST
  534. :set tw=0 wm=60 columns=80 noai fo=croq
  535. /serious/e
  536. a about life, the universe, and the rest
  537. ENDTEST
  538.  
  539. {
  540.  
  541. /* this is
  542.  * a real serious important big
  543.  * comment
  544.  */
  545.     /* insert " about life, the universe, and the rest" after "serious" */
  546. }
  547.  
  548. STARTTEST
  549. :set nocin
  550. /comments
  551. joabout life/happens
  552. jothere/below
  553. oline/this
  554. Ohello
  555. ENDTEST
  556.  
  557. {
  558.     /*
  559.      * Testing for comments, without 'cin' set
  560.      */
  561.  
  562. /*
  563. * what happens here?
  564. */
  565.  
  566.     /*
  567.        the end of the comment, try inserting a line below */
  568.  
  569.         /* how about
  570.                         this one */
  571. }
  572.  
  573. STARTTEST
  574. :set cin
  575. /vec2
  576. ==
  577. ENDTEST
  578.  
  579. {
  580.     var = this + that + vec[0] * vec[0]
  581.                       + vec[1] * vec[1]
  582.                       + vec2[2] * vec[2];
  583. }
  584.  
  585. STARTTEST
  586. :set cin
  587. :set cino=}4
  588. /testing1
  589. k2==/testing2
  590. k2==
  591. ENDTEST
  592.  
  593. {
  594.         asdf asdflkajds f;
  595.     if (tes & ting) {
  596.         asdf asdf asdf ;
  597.         asdfa sdf asdf;
  598.         }
  599.     testing1;
  600.     if (tes & ting)
  601.     {
  602.         asdf asdf asdf ;
  603.         asdfa sdf asdf;
  604.         }
  605.     testing2;
  606. }
  607.  
  608. STARTTEST
  609. :set cin
  610. :set cino=(0,)20
  611. /main
  612. =][
  613. ENDTEST
  614.  
  615. main ( int first_par, /*
  616.                        * Comment for
  617.                        * first par
  618.                        */
  619.           int second_par /*
  620.                        * Comment for
  621.                        * second par
  622.                        */
  623.      )
  624. {
  625.     func( first_par, /*
  626.                       * Comment for
  627.                       * first par
  628.                       */
  629.     second_par /*
  630.                       * Comment for
  631.                       * second par
  632.                       */
  633.         );
  634.  
  635. }
  636.  
  637. STARTTEST
  638. :set cin
  639. :set cino=
  640. ]]=][
  641. ENDTEST
  642.  
  643. {
  644.     do
  645.     {
  646.         if ()
  647.         {
  648.             if ()
  649.                 asdf;
  650.             else
  651.                 asdf;
  652.         }
  653.     } while ();
  654.             cmd;        /* this should go under the } */
  655. }
  656.  
  657. STARTTEST
  658. ]]=][
  659. ENDTEST
  660.  
  661. void f()
  662. {
  663.     if ( k() ) {
  664.         l();
  665.  
  666.     } else { /* Start (two words) end */
  667.         m();
  668.     }
  669.  
  670.     n();
  671. }
  672.  
  673. STARTTEST
  674. :set cino={s,e-s
  675. ]]=][
  676. ENDTEST
  677.  
  678. void f()
  679. {
  680.     if ( k() )
  681.     {
  682.         l();
  683.     } else { /* Start (two words) end */
  684.         m();
  685.     }
  686.         n();    /* should be under the if () */
  687. }
  688.  
  689. STARTTEST
  690. :set cino={s,fs
  691. ]]=/ foo
  692. ENDTEST
  693.  
  694. void bar(void)
  695. {
  696.     static array[2][2] =
  697.     {
  698.         { 1, 2 },
  699.         { 3, 4 },
  700.     }
  701.  
  702.     while (a)
  703.     {
  704.         foo(&a);
  705.     }
  706.  
  707.     {
  708.         int a;
  709.         {
  710.             a = a + 1;
  711.         }
  712.     }
  713.     b = a;
  714.     }
  715.  
  716. void func(void)
  717.     {
  718.     a = 1;
  719.     {
  720.         b = 2;
  721.     }
  722.     c = 3;
  723.     d = 4;
  724.     }
  725. /* foo */
  726.  
  727. STARTTEST
  728. :set cino=
  729. /while
  730. ohere
  731. ENDTEST
  732.  
  733. a()
  734. {
  735.   do {
  736.     a = a +
  737.       a;
  738.   } while ( a );        /* add text under this line */
  739.     if ( a )
  740.       a;
  741. }
  742.  
  743. STARTTEST
  744. :set cino= com=
  745. /comment
  746. olabel2: b();label3 /* post */:/* pre */ label4:f(/*com*/);if (/*com*/)cmd();
  747. ENDTEST
  748.  
  749. a()
  750. {
  751. label1:
  752.             /* hmm */
  753.             // comment
  754. }
  755.  
  756. STARTTEST
  757. :set comments& comments^=s:/*,m:**,ex:*/
  758. /simple
  759. =5j
  760. ENDTEST
  761.  
  762. /*
  763.   * A simple comment
  764.    */
  765.  
  766. /*
  767.   ** A different comment
  768.    */
  769.  
  770. STARTTEST
  771. :set cino=c0
  772. :set comments& comments-=s1:/* comments^=s0:/*
  773. 2kdd]]=][
  774. ENDTEST
  775.  
  776. void f()
  777. {
  778.  
  779.     /*********
  780.   A comment.
  781. *********/
  782. }
  783.  
  784. STARTTEST
  785. :set cino=c0,C1
  786. :set comments& comments-=s1:/* comments^=s0:/*
  787. 2kdd]]=][
  788. ENDTEST
  789.  
  790. void f()
  791. {
  792.  
  793.     /*********
  794.   A comment.
  795. *********/
  796. }
  797.  
  798. STARTTEST
  799. :set cino=
  800. ]]=][
  801. ENDTEST
  802.  
  803. void f()
  804. {
  805.     c = c1 &&
  806.     (
  807.     c2 ||
  808.     c3
  809.     ) && c4;
  810. }
  811.  
  812. STARTTEST
  813. :set cino=(s
  814. 2kdd]]=][
  815. ENDTEST
  816.  
  817. void f()
  818. {
  819.     c = c1 &&
  820.     (
  821.     c2 ||
  822.     c3
  823.     ) && c4;
  824. }
  825.  
  826. STARTTEST
  827. :set cino=(s,U1  
  828. 2kdd]]=][
  829. ENDTEST
  830.  
  831. void f()
  832. {
  833.     c = c1 &&
  834.     (
  835.     c2 ||
  836.     c3
  837.     ) && c4;
  838. }
  839.  
  840. STARTTEST
  841. :set cino=(0
  842. 2kdd]]=][
  843. ENDTEST
  844.  
  845. void f()
  846. {
  847.     if (   c1
  848.     && (   c2
  849.     || c3))
  850.     foo;
  851. }
  852.  
  853. STARTTEST
  854. :set cino=(0,w1  
  855. 2kdd]]=][
  856. ENDTEST
  857.  
  858. void f()
  859. {
  860.     if (   c1
  861.     && (   c2
  862.     || c3))
  863.     foo;
  864. }
  865.  
  866. STARTTEST
  867. :set cino=(s
  868. 2kdd]]=][
  869. ENDTEST
  870.  
  871. void f()
  872. {
  873.     c = c1 && (
  874.     c2 ||
  875.     c3
  876.     ) && c4;
  877.     if (
  878.     c1 && c2
  879.     )
  880.     foo;
  881. }
  882.  
  883. STARTTEST
  884. :set cino=(s,m1  
  885. 2kdd]]=][
  886. ENDTEST
  887.  
  888. void f()
  889. {
  890.     c = c1 && (
  891.     c2 ||
  892.     c3
  893.     ) && c4;
  894.     if (
  895.     c1 && c2
  896.     )
  897.     foo;
  898. }
  899.  
  900. STARTTEST
  901. :g/^STARTTEST/.,/^ENDTEST/d
  902. :1;/start of AUTO/,$wq! test.out
  903. ENDTEST
  904.